package com.lastproject.ejb.entities;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;

@Entity
@NamedQueries({
		@NamedQuery(name = "EmailGroup.findAll", query = "SELECT e FROM EmailGroup e"),
		@NamedQuery(name = "EmailGroup.findLastByName", query = "SELECT e FROM EmailGroup e WHERE e.name = :name") })
public class EmailGroup implements Serializable {

	private static final long serialVersionUID = 8175244964086051623L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "id")
	private int id;

	private String name;

	@OneToMany(mappedBy = "emailGroup")
	private List<Survey> surveys;

	@ManyToMany
	@JoinTable(name = "group_users", joinColumns = { @JoinColumn(name = "idGroup") }, inverseJoinColumns = { @JoinColumn(name = "idUser") })
	private List<User> users;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public List<Survey> getSurveys() {
		return surveys;
	}

	public void setSurveys(List<Survey> surveys) {
		this.surveys = surveys;
	}

	public List<User> getUsers() {
		return users;
	}

	public void setUsers(List<User> users) {
		this.users = users;
	}
}
